{# empty Twig template #}

{#Variables disponibles : style, start, end, content#}

{{ form_start(form, {'action': path('sm_form_action', {id: id_srt})}) }}
    {{ form_errors(form) }}

    <div class="style-container">
        {{ form_label(form.style) }}
        {{ form_errors(form.style) }}
        {{ form_widget(form.style) }}
    </div>

    <div class="start-container">
        {{ form_label(form.start) }}
        {{ form_errors(form.start) }}
        {{ form_widget(form.start) }}
    </div>
    
    <div class="end-container">
        {{ form_label(form.end) }}
        {{ form_errors(form.end) }}
        {{ form_widget(form.end) }}
    </div>

    <div class="content-container clearfix">
        {{ form_label(form.content) }}
        {{ form_errors(form.content) }}
        {{ form_widget(form.content) }}
    </div>

{{ form_end(form) }}

<script type="text/javascript">
    $(document).ready(function() {
        
        $("input#srt_start").mask("9:99:99.99", {placeholder:"0"});
        $("input#srt_end").mask("9:99:99.99", {placeholder:"0"});
        
        $('form[name="srt"]').submit(function() {
                
            $id = $(this).data('id');
            var Data = $(this).serialize();
            var route = '{{ path('sm_form_action', {'id': "PLACEHOLDER" }) }}';
            route = route.replace("PLACEHOLDER", $id);

            $.ajax({
                type: "POST",
                url: route,
                data: Data
            })
            .done(function( msg ) {
                
                if(msg.success == true) {
                    
                    $('div[data-id="'+msg.id+'"] .content').html(parseComment(msg.content));
                    $('div[data-id="'+msg.id+'"] .start').html(msg.start);
                    $('div[data-id="'+msg.id+'"] .end').html(msg.end);
                    $('div[data-id="'+msg.id+'"] .style').html(msg.style);
                    
                    //Get next formulaire
                    
                    
                }else{
                    console.log('nok');
                }
            });

            return false;

        });
    });
            
</script>